﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.Triggers.CCoEditTriggerCmd
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Collections.ObjectModel;
using System.Resources;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.Triggers;

public class CCoEditTriggerCmd : CCoCreateTriggerCmd
{
  private CApEditTriggerEnabler m_commandEditEnabler = new CApEditTriggerEnabler();

  public override void Execute(object cmdParams)
  {
    if (this.m_dialogIsOpen)
      return;
    CUiCreateTriggerDlg createTriggerDlg = new CUiCreateTriggerDlg((CCoCreateTriggerCmd) this, TriggerAction.EditTrigger);
    TxRoboticPaintTrigger trigger = (TxRoboticPaintTrigger) null;
    if (cmdParams != null && cmdParams is TxObjectList)
      trigger = ((Collection<ITxObject>) (cmdParams as TxObjectList))[0] as TxRoboticPaintTrigger;
    if (TxRoboticPaintTrigger.op_Inequality(trigger, (ITxObject) null))
    {
      createTriggerDlg.SetOrigTrigger(trigger);
      ((Control) createTriggerDlg).Show();
    }
    else
    {
      TxObjectList allItems = TxApplication.ActiveSelection.GetAllItems();
      if (((Collection<ITxObject>) allItems).Count != 1)
        return;
      createTriggerDlg.SetOrigTrigger(((Collection<ITxObject>) allItems)[0] as TxRoboticPaintTrigger);
      ((Control) createTriggerDlg).Show();
    }
  }

  public override bool Connect() => true;

  public override bool Licensed => TxCommandLicenser.EditTriggerLicense;

  public override string Tooltip
  {
    get
    {
      return new ResourceManager("DnProcessSimulateCommands.Triggers.StringTable", ((object) this).GetType().Assembly).GetString("CMD_TOOLTIP_EDIT");
    }
  }

  public override string Description
  {
    get
    {
      return new ResourceManager("DnProcessSimulateCommands.Triggers.StringTable", ((object) this).GetType().Assembly).GetString("CMD_DESCRIPTION_EDIT");
    }
  }

  public override string Name
  {
    get
    {
      return new ResourceManager("DnProcessSimulateCommands.Triggers.StringTable", ((object) this).GetType().Assembly).GetString("CMD_NAME_EDIT");
    }
  }

  public override string Bitmap
  {
    get
    {
      return new ResourceManager("DnProcessSimulateCommands.Triggers.StringTable", ((object) this).GetType().Assembly).GetString("EDIT_PAINT_TRIGGER_BMP");
    }
  }

  public override ITxCommandEnabler CommandEnabler => (ITxCommandEnabler) this.m_commandEditEnabler;

  public override ITxImage Image => (ITxImage) TxImageManager.GetImageByKey("EditPaintTrigger");
}
